//
//  ModifyPasswordViewController.m
//  ZFPlatform
//
//  Created by magus on 11-6-5.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "ModifyPasswordViewController.h"
#import "CTextField.h"


@implementation ModifyPasswordViewController

@synthesize panel;
@synthesize oldPassword;
@synthesize newPassword;
@synthesize rePassword;
@synthesize bindZaoHangBtn;


//通过xib资源初始化视图控制器
//
+ (ModifyPasswordViewController*) InitFromXib
{
	self = [[ModifyPasswordViewController alloc] 
			initWithNibName:@"ModifyPasswordViewController" bundle:nil];
	return self;
}


//初始化界面
//
- (void) InitAllViews
{
	//设置导航栏标题
	[self setTitle:@"修改注册邮箱"];
	
	//设置背景面板1成圆角显示
	[panel.layer setCornerRadius:12.0];
	
	//设置按钮背景
	UIImage* buttonImg = [UIImage imageNamed:@"按钮（大）.png"];
	[bindZaoHangBtn setBackgroundImage:buttonImg forState:UIControlStateNormal];
	[buttonImg release];
	
	//设置导航栏左按钮
	UIImage* image = [UIImage imageNamed: @"导航栏按钮（返回）.png"];
	CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
	UIButton* leftButton = [[UIButton alloc] initWithFrame:rect];
	[leftButton.titleLabel setFont:[UIFont boldSystemFontOfSize:13.0]];
	[leftButton setTitle:@" 返回" forState:UIControlStateNormal];
	[leftButton setBackgroundImage:image forState:UIControlStateNormal];
	[leftButton addTarget:self action:@selector(GoBack:) forControlEvents:UIControlEventTouchDown];
	UIBarButtonItem* leftItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
	self.navigationItem.leftBarButtonItem = leftItem;
	[leftItem release];
	[leftButton release];
	[image release];
}


//响应“返回”导航按钮
//
- (void) GoBack: (id) sender
{
	[self.navigationController popViewControllerAnimated:YES];
}


//使return键后退出软键盘
//
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}


//响应文本框开始编辑
//
- (IBAction) OnEditBegin: (id) sender
{
	CTextField* textField = (CTextField*)sender;
	
	[textField SetBorderWidth:4.0];
	[textField SetCornerRadius:8.0];
	[textField SetBorderColor:[UIColor orangeColor]];
	[textField setTextColor:[UIColor blackColor]];
}


//响应文本框编辑完毕
//
- (IBAction) OnEditEnd: (id) sender
{
	CTextField* textField = (CTextField*)sender;
	
	[textField SetBorderWidth:0.0];
	[textField setTextColor:[UIColor lightGrayColor]];
}


//响应“修改注册邮箱”按钮
//
- (IBAction) OnClick_BindZaoHang: (id) sender
{
	NSLog(@"OnClick_BindZaoHang");
}


// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
	[self InitAllViews];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc
{
	[panel release];
	[oldPassword release];
	[newPassword release];
	[rePassword release];
	[bindZaoHangBtn release];
	
    [super dealloc];
}


@end
